package com.zjw.zy.coreui.view

import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
import android.widget.Button
import android.widget.ImageView
import com.zjw.zy.R
import com.zjw.zy.base.BaseViewGroup

/**
 * @author ：zhong.jw
 * @date ：Created in 2022/9/28 18:46
 *
 * 左滑菜单(导航)
 */
class NaviSlideView : BaseViewGroup {

    companion object {
        private const val TAG = "NaviSlideView"

    }

    private val mCallLove: Button by lazy { findViewById(R.id.slide_btn_call_love) }
    private val mSetting: Button by lazy { findViewById(R.id.slide_btn_setting) }
    private val mAccess: Button by lazy { findViewById(R.id.slide_btn_access_info) }
    private val mTips: Button by lazy { findViewById(R.id.slide_btn_tips) }
    private val mCalendar: Button by lazy { findViewById(R.id.slide_btn_calendar) }
    private val image: ImageView by lazy { findViewById(R.id.slide_image) }

    private var mListener: OnListener? = null

    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    ) {
    }

    override fun onLayoutId(): Int {
        return R.layout.slide_nav_layout
    }

    fun setImage(drawable: Drawable) {
        this.image.background = drawable
    }

    override fun onBindListener() {
        mCallLove.setOnClickListener { mListener?.onCallLove() }

        mSetting.setOnClickListener { mListener?.onCallSetting() }

        mTips.setOnClickListener { mListener?.onCallTips() }

        mCalendar.setOnClickListener { mListener?.onCallCalendar() }

        mAccess.setOnClickListener { mListener?.onAccessClick() }
    }

    override fun onBindValue() {}
    override fun onFindView(rootView: View) {}
    fun bindListener(listener: OnListener) {
        mListener = listener
    }


    interface OnListener {
        fun onCallLove()

        fun onCallSetting()

        fun onCallTips()

        fun onCallCalendar()

        fun onAccessClick()
    }
}